package demo01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import demo01.Player;

public class work08 {
	public static void main(String[] args) {
		ArrayList<String> poker=new ArrayList<String>();
		String[] colors={"♥","♣","♦","♠"}; 
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		poker.add("大王");
		poker.add("小王");
		
		for(String number:numbers){
			for(String color:colors){
				poker.add(color+number);
			}
		}
		Collections.shuffle(poker);
		Player player1=new Player("laoli");
		Player player2=new Player("laowang");
		Player player3=new Player("laoliu");
		
		ArrayList<String> list1 =new ArrayList<String>();
		ArrayList<String> list2 =new ArrayList<String>();
		ArrayList<String> list3 =new ArrayList<String>();
		Map<Integer, String> map = poker.stream().collect(Collectors.toMap(s->poker.indexOf(s), s->s));
//		System.out.println(map);
		
		List<Integer>list = map.keySet().stream().collect(Collectors.toList());
//		System.out.println(list);
		list.stream().filter(s->(list.indexOf(s)+1)%3==0&&list.indexOf(s)+1<=51).forEach(s->list1.add(map.get(s)));
		System.out.println(list1);
		list.stream().filter(s->(list.indexOf(s)+1)%3==1&&list.indexOf(s)+1<=51).forEach(s->list2.add(map.get(s)));
		list.stream().filter(s->(list.indexOf(s)+1)%3==2&&list.indexOf(s)+1<=51).forEach(s->list3.add(map.get(s)));
		Collections.sort(list1);
		Collections.sort(list2);
		Collections.sort(list3);
		
		System.out.println(player1.getName()+list1);
		System.out.println(player2.getName()+list2);
		System.out.println(player3.getName()+list3);
	}
}
